import java.util.Stack;

class Solution {
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();
        for (String x:tokens) {
            if(!isoperation(x)){
                stack.push(Integer.parseInt(x));
            }else{
                int num1=stack.pop();
                int num2=stack.pop();
                switch (x){
                    case "+":
                        stack.push(num2+num1);
                        break;
                    case "-":
                        stack.push(num2-num1);
                        break;
                    case "/":
                        stack.push(num2/num1);
                        break;
                    case "*":
                        stack.push(num2*num1);
                        break;
                }
            }

        }
        return stack.pop();

    }
    protected  boolean isoperation(String x){
        if(x.equals("*")||x.equals("/")||
           x.equals("+")||x.equals("-")){
            return true;
        }
     return false;
    }
}